package com.xu.sso.core.utils;


import com.xu.sso.core.enums.ErrorMessage;
import com.xu.sso.core.exception.SSOException;

public class ExceptionUtil {

    public static SSOException createException(ErrorMessage errorMessage) {
        return new SSOException(errorMessage.getErrCode(), errorMessage.getErrMsg());
    }

    public static SSOException createException(ErrorMessage errorMessage, Throwable e) {
        return new SSOException(errorMessage.getErrMsg(), e);
    }

    public static SSOException createException(Throwable e) {
        return new SSOException(e);
    }

    public static SSOException createException(String errCode) {
        return new SSOException(errCode, ErrorMessage.getErrorMessage(errCode).getErrMsg());
    }

}
